package org.l.qiao.base;

import org.bson.types.ObjectId;
import org.l.qiao.annotation.Key;

/**
 * Created by LBW05 on 2016/7/9.
 */
public class LObjectId implements LType {
    @Override
    public int getLType() {
        return LTYPE_OBJECTID;
    }

    @Override
    public Object parse(Key key, String value) {
        if (value == null || value.length() == 0)
            return null;

        return new ObjectId(value);
    }

    @Override
    public Object parse(String value) {
        if (value == null || value.length() == 0)
            return null;

        return new ObjectId(value);
    }

    @Override
    public String toString(Object object) {
        return String.valueOf(object);
    }
}
